<template>
  <div class="loginRegisterFrom-box">
    <div class="title">BIDEA-Admin</div>
    <form action="javascript:;" method="post" class="loginRegisterFrom">
      <section>
        <label class="label1">
          <p>登录授权码</p><input type="text" v-model="code" placeholder=" " required>
          <div class="border"></div>
        </label>
        <button type="submit" id="submit" @click="tips">登录</button>
      </section>
    </form>
  </div>
</template>

<script>
    export default {
        name: "AdminLogin",
        data(){
            return{
                code:'',
                baseURL:'http://localhost:8081/adminLog/login/'
            }
        },
        mounted(){
          if (this.$route.query.code == "true") {
              this.$message.success("【授权码】以发送到您的邮箱")
          } else {
              this.$router.push('/adminPage/loginCode')
          }
        },
        methods:{
            tips(){
                if (this.code==''){
                    this.$message.warning("【登录授权码】不能为空")
                } else {
                    this.axios.post(this.baseURL+this.code).then((res)=>{
                        if (res.data==false){
                            this.failOpt("登录失败")
                        }else {
                            this.successOpt("登录成功")
                            this.$router.push('/adminPage')

                        }
                    }).catch(
                        exception=>{
                            console.log(exception)
                        }
                    )
                }
            },
            successOpt(message) {
                this.$notify({
                    title: '成功',
                    message: message,
                    type: 'success'
                })
            },
            failOpt(message) {
                this.$notify.error({
                    title: '错误',
                    message: message
                });
            }
        }
    }
</script>

<style scoped>
  .loginRegisterFrom-box{
    position: relative;
    width: 550px;
    padding: 30px 40px;
    overflow: hidden;
    background-color: #fdfdfd;
    box-shadow: 0 0 20px rgb(180, 180, 180);
    border-radius: 3px;
    letter-spacing: 2px;
    z-index: 999;
    transform-origin:center;

    /* 绝对定位 */
    position:absolute;
    /* 水平居中 */
    left:50%;
    /* 垂直居中  */
    top:50%   ;
    /* 内容相对父元素水平垂直居中 */
    -webkit-transform:translate(-50%,-50%);
    /* 内容相对父元素水平垂直居中 */
    -moz-transform:translate(-50%,-50%);
    /* 内容相对父元素水平垂直居中 */
    transform:translate(-50%,-50%);
  }
  .title{
    width: 100%;
    height: 50px;
    line-height: 20px;
    text-align: center;
    font-weight: bolder;
    font-size: 17px;
    color: #525252;
  }
  .loginRegisterFrom section label {
    display: block;
    margin-bottom: 15px;
    position: relative
  }
  .loginRegisterFrom section label p {
    color: rgb(58, 58, 58);
    margin: 0 0 10px 0;
    font-weight: 600;
    font-size: 12px;
    opacity: .8;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }

  .loginRegisterFrom section label input {
    width: 100%;
    display: block;
    border: 0;
    background: transparent;
    color: rgb(58, 58, 58);
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    padding: 0 0 10px;
    box-sizing: border-box;
    font-weight: 600;

  }

  .loginRegisterFrom section label input:focus~.border {
    transform: scale(1, 1);
  }

  .loginRegisterFrom section label .border {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgb(58, 58, 58);
    transform: scale(0, 1);
    transition: .2s ease;
  }

  .loginRegisterFrom section label:last-child {
    margin-bottom: 0;
  }
  .label1{
    height: 48px;
    transition: 0.2s;
    overflow: hidden;
    /*background-color: tomato;*/
  }
  .loginRegisterFrom section button {
    background: #05a090;
    border: 0;
    width: 100%;
    padding: 10px 0;
    font-weight: 600;
    border-radius: 3px;
    color: rgb(236, 236, 236);
    cursor: pointer;
    letter-spacing: 2px;
    margin-top: 15px;
  }

  .loginRegisterFrom section button:hover {
    background: #009788;
    color: rgb(255, 255, 255);
  }
</style>
